package acwing.动态规划;

import java.util.Scanner;

/**
 * 地宫取宝
 *
 * @author yang
 * @date 2021/12/12
 */
public class 地宫取宝 {

    static int N = 55;
    static int[][] w = new int[N][N];
    static int[][][][] f = new int[N][N][13][14];
    static int n,m,k;
    static int mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                w[i][j] = sc.nextInt();
                w[i][j]++;
            }
        }

        f[1][1][1][w[1][1]] = 1;
        f[1][1][0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (i == 1 && j == 1) continue;
                for (int u = 0; u <= k; u++) {
                    for (int v = 0; v <= 13; v++) {
                        int val = f[i][j][u][v];
                        val = (val + f[i - 1][j][u][v]) % mod;
                        val = (val + f[i][j - 1][u][v]) % mod;
                        if (u >0 && v == w[i][j]) {
                            for (int c = 0; c < v; c++) {
                                val = (val + f[i - 1][j][u - 1][c]) % mod;
                                val = (val + f[i][j - 1][u - 1][c]) % mod;
                            }

                        }
                        f[i][j][u][v] = val;
                    }
                }
            }
        }
        int res = 0;
        for (int i = 0; i <= 13; i++) res = (res + f[n][m][k][i]) % mod;
        System.out.println(res);
    }
}
